# -*- coding:utf-8 -*-
class Solution:
    def maxInWindows(self, num, size):
        # write code here
        if not size:
            return []
        res = []
        num_window = len(num) - size + 1
        for i in range(num_window):
            res.append(max(num[i: size+i]))
        return res




class Solution:
    def maxInWindows(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: List[int]
        """
        if not nums or not k:
            return []
        res = []
        windows = []
        for i, value in enumerate(nums):
            if i >= k and windows[0] <= i-k:
                windows.pop(0)
            while windows and value > nums[windows[-1]]:
                windows.pop()
            windows.append(i)
            if i >= k-1 :
                res.append(nums[windows[0]])
            print(windows)
        return res